The IP address is ANDed with the subnet mask to extract the network ID for the local network on which the host resides. The subnet mask enables you to extract the Network ID. IP looks to see if the destination host is local or remote to sending host. If IP address is remote, then routing tables are used to figure out where packet needs to be sent.
Subnetting enables one to take a single IP address (whether it be from an ISP or the Internic) and make a group of networks out of single IP address. To the outside world, the network ID looks like a single network.
A subnet is a physical segment in a TCP/IP environment that uses IP addresses derived from a single network ID. Dividing the network into subnets requires that each segment use a different network ID, or subnet. A unique subnet ID is created for each segment by partitioning the bits in the host ID into two parts. One part is used to identify the segment as a unique network and the other part is used to identify the hosts. (If you are using a private network, subnetting is not necessary).
Subnetting allows you to mix different technologies (Ethernet and Token Ring), overcome limitations of current technologies, such as exceeding the maximum number of hosts per segment, and reduces network congestion by redirecting traffic and reducing broadcasts. (Subnetting is defined in RFC 950)
Subnet mask is used to remove the host ID so that only the network ID remains. Meaning all bits you are masking out (0s) are used for the host ID.
Before you implement subnetting, you need to determine the current requirements and plan for future requirements (growth).
Guidelines for Subnetting:
Determine the number of physical segments on your network
Determine the number of required host for each physical segment (each host/node requires at least one IP address)
Based on requirements you need to Define one subnet mask, a unique subnet ID for each physical segment, and a range of host IDs for each subnet.Locate users that share data with each other on the same subnet
Put a domain controller on each subnet that users logon to
Place users with heavy network usage on less populated subnets
When possible, put users on the same subnet as the servers they will use
(If required, put multiple network cards in servers that server multiple subnets) (IP Forwarding))
2n | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
decimal | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
# network of bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Subnet Mask | 0 | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 |
# of subnets | 2 | 6 | 14 | 30 | 62 | 126 | |||
# of host bits | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
variation of table 6.8 in book on page 101
Mask | Binary | Bits Used for Network ID |
128 | 10000000 | 1 |
192 | 11000000 | 2 |
224 | 11100000 | 3 |
240 | 11110000 | 4 |
248 | 11111000 | 5 |
252 | 11111100 | 6 |
254 | 11111110 | 7 |
255 | 11111111 | 8 |
To determine the Number of Networks 2n - 2
Mask | Binary | Bits Used for Network ID | Available Host Bits |
128 | 10000000 | 1 | 7 |
192 | 11000000 | 2 | 6 |
224 | 11100000 | 3 | 5 |
240 | 11110000 | 4 | 4 |
248 | 11111000 | 5 | 3 |
252 | 11111100 | 6 | 2 |
254 | 11111110 | 7 | 1 |
255 | 11111111 | 8 | 0 |
To Get the number of Host IDs = 2n - 2
For an IP address to be a remote address, the network portion of the address (1's) must be different (binary) from your own.
(Note: These examples are using a Class C IP address)
Example 1:
We need 60 networks, and we don't care how many hosts per network we have.
26 - 2 = 64 - 2 = 62 subnets
Using 6 extra bits from host id we can create 62 subnets
22 - 2 = 4 - 2 = 2 hosts per subnets
However, this would only leave 2 bits left for our host. Using a subnet mask of 255.255.255.252 (11111111.11111111.11111111.11111100) means we are using 30 bits for Network ID and only 2 bits to determine the number of hosts per network.
Example 2:
Number of networks is irrelevant but we do need 50 hosts per segment.
26 - 2 = 64 - 2 = 62 hosts per subnets
22 - 2 = 4 - 2 = 2 subnets
A 192 mask (11000000)network gives us 62 hosts per network segment with 2 bits left over for the network segment, which would give us only 2 network segments. Using a subnet mask of 255.255.255.192 (11111111.11111111.11111111.11000000) means we are using 26 bits for Network ID and only 6 bits to determine the number of hosts per network.
Example 3:
We need at least 10 networks (subnets)
24 - 2 = 16 - 2 = 14 subnets
A 240 (11110000) network gives us 10 networks plus 4 more to grow.
Now, we need at least 14 Hosts per subnet
24 - 2 = 16 - 2 = 14 hosts per subnets
This gives us 14 hosts per subnet exact number
Therefore, I could use the subnet mask of 255.255.255.240. (11111111.11111111.11111111.11110000). This would give me exactly 14 Subnets and 14 hosts per subnet. Growth can occur with number of networks but not the number of hosts per network.
Example 4:
We need 10 networks and 50 Hosts per network segment
Once again, we can use a 240 (11110000) network because we only need 10 subnets and a 240 network will give us 14 networks. However, we need at least 50 host per subnet.
So to determine this we will need to add bits to host ID.
212 - 2 = 4096 - 2 = 4094 hosts per subnets
Therefore I could use the subnet mask of 255.255.240.0 (11111111.11111111.11110000.00000000). This would give us 14 subnets with 4096 host per subnet. Growth can occur with number of networks and with the number of hosts per network.
Example 5:
We need 5 networks and 50 hosts per network segment
A 240 network gave us 14 subnets, and we need 5 subnets (if you subtract a bit from 240 network ID, we get 224)
23 - 2 = 8 - 2 = 6 subnets
So a 224 (11100000) network gives us 6 subnets (we can use this)
Now we need to get the number of host (50 host) per network.
213 - 2 = 8192- 2 = 8190 hosts per subnets
255.255.224.0 (11111111.11111111.11100000.00000000) Here we are using 19 bits to determine the Network ID and 13 bits to get the number of hosts per network.
So far, we have learned how setup required number of subnets (networks) and the number of hosts per subnet (network). Now we need to determine the Sub Network ID. In other words, the network address for each subnet.
Look at pages 99 - 101. Also on handout page 133.
OK, so what does this mean? Let's look at table 6.6 on pages 99 - 100. If you notice the first part of the octet (bits of subnet mask) it is being increased by 1 each time, while the other bits are being ignored. You always end up counting by the position value of the last bit in the subnet mask.
There is another method (formula) for determining the Sub Network ID.
256 - (subnet mask) = sub network IDs
In Table 6.6 of text they are using a 240 subnet (using 4 bits).
256 - 240 = 16 (4 bits used)
The first 15 bits are invalid, the first valid network starts at .16 , this is incremented by 16 up to but not inclusive of the subnet mask (240)
with a 240 subnet mask the available networks are as follows
Decimal | Binary | |
0 | 0000 | invalid |
16 | 0001 | 160.16.16.0 |
32 | 0010 | 160.16.32.0 |
48 | 0011 | 160.16.48.0 |
64 | 0100 | 160.16.64.0 |
80 | 0101 | 160.16.80.0 |
96 | 0110 | 160.16.96.0 |
112 | 0111 | 160.16.112.0 |
128 | 1000 | 160.16.128.0 |
144 | 1001 | 160.16.144.0 |
160 | 1010 | 160.16.160.0 |
176 | 1011 | 160.16.176.0 |
192 | 1100 | 160.16.192.0 |
208 | 1101 | 160.16.208.0 |
224 | 1110 | 160.16.224.0 |
240 | 1111 | invalid |
Likewise using Table 6.7 example from the book
256 - 224 = 32 (3 bits used)
The first 32 address are invalid. The first valid network is .32, this is incremented by 32 up to but not inclusive of the subnet mask (224)
Decimal | Binary | |
0 | 000 | invalid |
32 | 001 | 160.16.32.0 |
64 | 010 | 160.16.64.0 |
96 | 011 | 160.16.96.0 |
128 | 100 | 160.16.128.0 |
160 | 101 | 160.16.160.0 |
192 | 110 | 160.16.192.0 |
224 | 111 | 160.16.224.0 |
Sub Network IDs
Decimal | Binary | Network ID |
0 | 0000 | invalid network |
16 | 0001 | 160.16.16.0 |
32 | 0010 | 160.16.32.0 |
48 | 0011 | 160.16.48.0 |
64 | 0100 | 160.16.64.0 |
80 | 0101 | 160.16.80.0 |
96 | 0110 | 160.16.96.0 |
112 | 0111 | 160.16.112.0 |
128 | 1000 | 160.16.128.0 |
144 | 1001 | 160.16.144.0 |
160 | 1010 | 160.16.160.0 |
176 | 1011 | 160.16.176.0 |
192 | 1100 | 160.16.192.0 |
208 | 1101 | 160.16.208.0 |
224 | 1110 | 160.16.224.0 |
240 | 1111 | invalid network |
Using the above Sub network IDs you can determine the host IDs (IP addresses) for each of the subnets created.
Let's look at 160.16.16.0
To find the first Host ID for 160.16.16.0 network
you must add 1 bit to host portion of IP address 160.16.16.1
To find the last Host ID for for 160.16.16.0 network
you must subtract 1 bit from the broadcast (160.16.31.255) for that network ID 160.16.31.254
So, the first network ID host range is
160.16.16.1 - 160.16.31.254